(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/**
 * 页面加载动画插件
 * @module loading
 * @author xjc
 */

var extend = require('extend');

function Loading() {

    this.loadingDOM = null;
    /**
     * 保存容器原来的overflow属性
     * @type {String}
     */
    this.containerOverflow = '';

}

Loading.prototype.defaultOptions = {
    /**
     * 作为加载动画的元素
     * @type {String|Node}
     */
    element: '<img src="" alt="" />',
    // img: "default",
    // size: "auto",
    /**
     * 加载动画的容器
     * @type {String}
     */
    container: 'body',
    /**
     * 加载动画背景的颜色
     * @type {String}
     */
    maskColor: 'none'
};

/**
 * 初始化
 * @param  {Object} options 用户选项
 */
Loading.prototype.init = function(options) {
    extend(this, this.defaultOptions, options);
    this.render();
}

/**
 * 渲染组件
 */
Loading.prototype.render = function() {
    var self = this;

    // 装载元素
    self.loadingDOM = $('<div class="loading"><div class="middle"></div></div>');
    self.loadingDOM.find('.middle').append(self.element);
    var $container = $(self.container);
    $container.append(self.loadingDOM);


    // 添加样式
    var containerHeight = $(self.container).innerHeight();
    if(self.container === 'body') {
        containerHeight = '100%';
    }

    self.loadingDOM.css({
        'width': '100%',
        'height': containerHeight,
        'display': 'table',
        'position': 'absolute',
        'z-index': '999999999999999999',
        'left': '0',
        'top': '0',
        'background': self.maskColor,
        'text-align': 'center',

    })

    self.loadingDOM.find('.middle').css({
        'display': 'table-cell',
        'vertical-align': 'middle'
    })


    self.loadingDOM.css({
        display: 'none'
    })

    if ($container.css("position") === 'static') {
        $container.css("position", "relative")
    }

}

/**
 * 显示加载动画元素
 * @return {[type]} [description]
 */
Loading.prototype.show = function() {
    var self = this;

    var containerHeight = $(self.container).innerHeight();
    if(self.container === 'body') {
        containerHeight = '100%';
    }
    $(self.loadingDOM).css({
        display:'table',
        height:containerHeight
    });

    // 保存容器overflow状态
    self.containerOverflow = $(self.container).css('overflow');
    // 去除页面滚动条
    $(self.container).css({
        'overflow':'hidden'
    })
}

/**
 * 隐藏加载动画元素
 * @return {[type]} [description]
 */
Loading.prototype.hide = function() {
    var self = this;

    $(this.loadingDOM).hide();

    // 还原页面滚动条
    $(self.container).css({
        'overflow':self.containerOverflow
    })
}


/**
 * 导出插件
 * @param  {object} options 用户选项
 * @return {Loading}        插件的实例
 */
module.exports = function(options){
    var loading = new Loading();
    loading.init(options);
    return loading;
}

if(!!window.loading){throw new Error('全局变量冲突，loading')}else{window.loading = module.exports}

},{"extend":2}],2:[function(require,module,exports){
'use strict';

var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;

var isArray = function isArray(arr) {
	if (typeof Array.isArray === 'function') {
		return Array.isArray(arr);
	}

	return toStr.call(arr) === '[object Array]';
};

var isPlainObject = function isPlainObject(obj) {
	if (!obj || toStr.call(obj) !== '[object Object]') {
		return false;
	}

	var hasOwnConstructor = hasOwn.call(obj, 'constructor');
	var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
	// Not own constructor property must be Object
	if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
		return false;
	}

	// Own properties are enumerated firstly, so to speed up,
	// if last one is own, then all properties are own.
	var key;
	for (key in obj) {/**/}

	return typeof key === 'undefined' || hasOwn.call(obj, key);
};

module.exports = function extend() {
	var options, name, src, copy, copyIsArray, clone,
		target = arguments[0],
		i = 1,
		length = arguments.length,
		deep = false;

	// Handle a deep copy situation
	if (typeof target === 'boolean') {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
		target = {};
	}

	for (; i < length; ++i) {
		options = arguments[i];
		// Only deal with non-null/undefined values
		if (options != null) {
			// Extend the base object
			for (name in options) {
				src = target[name];
				copy = options[name];

				// Prevent never-ending loop
				if (target !== copy) {
					// Recurse if we're merging plain objects or arrays
					if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
						if (copyIsArray) {
							copyIsArray = false;
							clone = src && isArray(src) ? src : [];
						} else {
							clone = src && isPlainObject(src) ? src : {};
						}

						// Never move original objects, clone them
						target[name] = extend(deep, clone, copy);

					// Don't bring in undefined values
					} else if (typeof copy !== 'undefined') {
						target[name] = copy;
					}
				}
			}
		}
	}

	// Return the modified object
	return target;
};


},{}]},{},[1]);
